import pandas as pd

# 读取数据
df = pd.read_csv("WCPFC_PS_M_Grid1_Temp_SSH_MLT_2010_2019.csv")



# 构造x轴：日期
dates = pd.PeriodIndex(year=df["Year"],month=df["Month"],day=df["days"],freq="D")   # 注意：PeriodIndex类型不能直接画图
dates = dates.to_timestamp()  # 所以，需转为DatetimeIndex
df.info()
df.head()

# 可视化
from matplotlib import pyplot as plt
fig,ax = plt.subplots(2,2,figsize=(15,10))

# 气温
ax[0,0].plot(dates,df["Temp_0"])
ax[0,0].set_xlabel("Date")
ax[0,0].set_ylabel("Temperature ")
ax[0,0].set_title("Temp")


ax[0,0].plot(dates,df["Temp_50"])
ax[0,0].set_xlabel("Date")
ax[0,0].set_ylabel("Temperature ")
ax[0,0].set_title("Temp")


ax[0,0].plot(dates,df["Temp_100"])
ax[0,0].set_xlabel("Date")
ax[0,0].set_ylabel("Temperature ")
ax[0,0].set_title("Temp")


ax[0,0].plot(dates,df["Temp_150"])
ax[0,0].set_xlabel("Date")
ax[0,0].set_ylabel("Temperature ")
ax[0,0].set_title("Temp")


ax[0,0].plot(dates,df["Temp_200"])
ax[0,0].set_xlabel("Date")
ax[0,0].set_ylabel("Temperature ")
ax[0,0].set_title("Temp")


ax[0,0].plot(dates,df["Temp_250"])
ax[0,0].set_xlabel("Date")
ax[0,0].set_ylabel("Temperature ")
ax[0,0].set_title("Temp")


ax[0,0].plot(dates,df["Temp_300"])
ax[0,0].set_xlabel("Date")
ax[0,0].set_ylabel("Temperature ")
ax[0,0].set_title("Temp")
ax[0,0].legend()


plt.show()
# 风速

'''
# 降水
ax[1,0].plot(dates,df["SSH"],"r-")
ax[1,0].set_xlabel("Date")
ax[1,0].set_ylabel("SSH")
ax[1,0].set_title("SSH")

ax[1,1].plot(dates,df["MLT"],"ro")
ax[1,1].set_xlabel("Date")
ax[1,1].set_ylabel("MLT")
ax[1,1].set_title("MLT")
plt.show()

'''

'''
ax[0,1].plot(dates,df["skj_c_una"],"r-")
ax[0,1].set_xlabel("Date")
ax[0,1].set_ylabel("skj_c_una")
ax[0,1].set_title("skj_c_una")



# 构建季度特征
seasons = []

# 输出所有月份
for month in df["Month"]:
    # print(month)

    # 判断month在哪个区间
    if month in [12,1,2]:
        seasons.append('winter')
    elif month in [3,4,5]:
        seasons.append('spring')
    elif month in [6,7,8]:
        seasons.append('summer')
    elif month in [9,10,11]:
        seasons.append('fall')

# 构建特征
reduced_features = df.loc[:,['Temp_0','Temp_50','Temp_100','Temp_150']]
reduced_features['season'] = seasons
import seaborn as sns

sns.pairplot(reduced_features,hue='season',diag_kind='kde')
plt.show()
'''
